{include file="public/header"}
<div class="x-body">
    <form class="layui-form" action="{:url('Menu/update')}" method="post">
        <div class="layui-form-item">
            <label for="pid" class="layui-form-label">
                <span class="x-red">*</span>上级菜单
            </label>
            <div class="layui-input-inline">
                <select id="pid" name="pid" class="valid">
                    <option value="0">上级菜单</option>
                    {foreach name="list" item="m_list"}
                    <option value="{$m_list.id}" {if condition="$m_list.id eq $menu.id"}disabled="disabled"{/if}{if condition="$m_list.id eq $menu.pid"}selected="selected"{/if}>{neq name="m_list" value="1"}|{php}echo str_repeat('--', $m_list['level']*2);{/php}{/neq}{$m_list.title}</option>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="title" class="layui-form-label">
                <span class="x-red">*</span>菜单名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="title" name="title" required="" lay-verify="required"
                       autocomplete="off" value="{$menu.title}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                <span class="x-red">*</span>控制器方法
            </label>
            <div class="layui-input-inline">
                <input type="text" id="name" name="name" required="" lay-verify="name"
                       autocomplete="off" value="{$menu.name}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>如：admin/index/index
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="1" title="显示" {if condition="$menu.status eq 1"}checked=""{/if}>
                <input type="radio" name="status" value="0" title="隐藏" {if condition="$menu.status eq 0"}checked=""{/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="icon" class="layui-form-label">
                图标
            </label>
            <div class="layui-input-inline">
                <input type="text" id="icon" name="icon" lay-verify="icon"
                       autocomplete="off" value="{$menu.icon}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="sort" class="layui-form-label">
                排序
            </label>
            <div class="layui-input-inline">
                <input type="hidden" name="id" value="{$menu.id}">
                <input type="text" id="sort" name="sort" required="" lay-verify="sort"
                       autocomplete="off" value="{$menu.sort}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <button  class="layui-btn" lay-filter="*" lay-submit="">
                增加
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;

        //自定义验证规则
        form.verify({
            nikename: function(value){
                if(value.length < 5){
                    return '昵称至少得5个字符啊';
                }
            }
            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }
        });

    });
</script>
</body>

</html>